/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ma.projet.beans;

import ma.projet.facade.PersonneFacadeLocal;
import ma.projet.abstracts.AbstractFacade;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import ma.projet.model.Personne;

/**
 *
 * @author Mariama
 */
@Stateless
public class PersonneFacade extends AbstractFacade<Personne> implements PersonneFacadeLocal {
    @PersistenceContext(unitName = "InwiPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public PersonneFacade() {
        super(Personne.class);
    }
    @Override
    public Personne login(Personne pe)
    {Personne p=null;
       try{
        p=(Personne)em.createNamedQuery("Personne.login").setParameter("user",pe.getUser()).setParameter("pass",pe.getPass()).getSingleResult();
        
       }catch(Exception ex){
           System.out.println(ex.getMessage());
           return null;
       }
        return p;
    
    }
}
